/*
 * CompatScrollView.java
 * business
 *
 * Created by ChenTao on 2017/2/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/** 带滑动监听的ScrollView */
public class CompatScrollView extends ScrollView {

    private OnScrollChangedListener onScrollChangedListener;

    public CompatScrollView(Context context) {
        super(context);
    }

    public CompatScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CompatScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setOnScrollListener(OnScrollChangedListener onScrollChangedListener) {
        this.onScrollChangedListener = onScrollChangedListener;
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldX, int oldY) {
        super.onScrollChanged(x, y, oldX, oldY);
        if (onScrollChangedListener != null) {
            onScrollChangedListener.onScrollChanged(x, y, oldX, oldY);
        }
    }

    public interface OnScrollChangedListener {
        void onScrollChanged(int x, int y, int oldxX, int oldY);
    }
}
